using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace RiceShop.Models
{
    /// <summary>
    /// 订单商品实体
    /// </summary>
    [Table("OrderItem")]
    public class OrderItem
    {
        /// <summary>
        /// 订单商品ID
        /// </summary>
        [Key]
        public long Id { get; set; }

        /// <summary>
        /// 订单ID
        /// </summary>
        public long OrderId { get; set; }

        /// <summary>
        /// 商品SPU ID
        /// </summary>
        public long SpuId { get; set; }

        /// <summary>
        /// 商品SKU ID
        /// </summary>
        public long SkuId { get; set; }

        /// <summary>
        /// 商品标题
        /// </summary>
        [Required]
        [StringLength(255)]
        public string Title { get; set; } = string.Empty;

        /// <summary>
        /// 商品图片
        /// </summary>
        [StringLength(500)]
        public string? PrimaryImage { get; set; }

        /// <summary>
        /// 商品规格
        /// </summary>
        [StringLength(200)]
        public string? Specs { get; set; }

        /// <summary>
        /// 商品单价
        /// </summary>
        [Column(TypeName = "decimal(18,2)")]
        public decimal SalePrice { get; set; }

        /// <summary>
        /// 购买数量
        /// </summary>
        public int Quantity { get; set; }

        /// <summary>
        /// 商品总价
        /// </summary>
        [Column(TypeName = "decimal(18,2)")]
        public decimal TotalAmount { get; set; }

        /// <summary>
        /// 关联的订单
        /// </summary>
        public virtual Order Order { get; set; } = null!;
    }
} 